/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package com.mx.saco.entity;

import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

/**
 *
 * @author jethro.gutierrez
 */
@Entity
@Table(name = "tr_comprobante_concepto")
@NamedQueries({
    @NamedQuery(name = "ComprobanteConcepto.findAll", query = "SELECT c FROM ComprobanteConcepto c"),
    @NamedQuery(name = "ComprobanteConcepto.findByIdComprobante", query = "SELECT c FROM ComprobanteConcepto c WHERE c.comprobanteConceptoPK.idComprobante = :idComprobante"),
    @NamedQuery(name = "ComprobanteConcepto.findByIdConcepto", query = "SELECT c FROM ComprobanteConcepto c WHERE c.comprobanteConceptoPK.idConcepto = :idConcepto"),
    @NamedQuery(name = "ComprobanteConcepto.findByConsecutivo", query = "SELECT c FROM ComprobanteConcepto c WHERE c.comprobanteConceptoPK.consecutivo = :consecutivo"),
    @NamedQuery(name = "ComprobanteConcepto.findByCantidad", query = "SELECT c FROM ComprobanteConcepto c WHERE c.cantidad = :cantidad")})
public class ComprobanteConcepto implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected ComprobanteConceptoPK comprobanteConceptoPK;
    @Column(name = "cantidad")
    private Long cantidad;
    @JoinColumn(name = "id_concepto", referencedColumnName = "id_concepto", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Concepto concepto;
    @JoinColumn(name = "id_comprobante", referencedColumnName = "id_comprobante", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Comprobante comprobante;

    public ComprobanteConcepto() {
    }

    public ComprobanteConcepto(ComprobanteConceptoPK comprobanteConceptoPK) {
        this.comprobanteConceptoPK = comprobanteConceptoPK;
    }

    public ComprobanteConcepto(int idComprobante, int idConcepto, int consecutivo) {
        this.comprobanteConceptoPK = new ComprobanteConceptoPK(idComprobante, idConcepto, consecutivo);
    }

    public ComprobanteConceptoPK getComprobanteConceptoPK() {
        return comprobanteConceptoPK;
    }

    public void setComprobanteConceptoPK(ComprobanteConceptoPK comprobanteConceptoPK) {
        this.comprobanteConceptoPK = comprobanteConceptoPK;
    }

    public Long getCantidad() {
        return cantidad;
    }

    public void setCantidad(Long cantidad) {
        this.cantidad = cantidad;
    }

    public Concepto getConcepto() {
        return concepto;
    }

    public void setConcepto(Concepto concepto) {
        this.concepto = concepto;
    }

    public Comprobante getComprobante() {
        return comprobante;
    }

    public void setComprobante(Comprobante comprobante) {
        this.comprobante = comprobante;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (comprobanteConceptoPK != null ? comprobanteConceptoPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof ComprobanteConcepto)) {
            return false;
        }
        ComprobanteConcepto other = (ComprobanteConcepto) object;
        if ((this.comprobanteConceptoPK == null && other.comprobanteConceptoPK != null) || (this.comprobanteConceptoPK != null && !this.comprobanteConceptoPK.equals(other.comprobanteConceptoPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.mx.saco.entity.ComprobanteConcepto[ comprobanteConceptoPK=" + comprobanteConceptoPK + " ]";
    }
    
}
